﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Web;

namespace LynxWebLog
{
    public class CssStrings
    {
        const string DefPriColor = "#35a207";
        const string DefPriDarkColor = "#2a810c";
        const string DefBrdColor = "#0aeb49";
        const string DefBrdDarkColor = "#27770b";
        const string DefBgColor = "#edf9f9";
        public string PriColor { get; set; }
        public string PriDarkColor { get; set; }
        public string BgColor { get; set; }
        public string BrdrColor { get; set; }
        public string BrdrDarkColor { get; set; }

        public CssStrings() { }

        public void SetColors(string pcol = DefPriColor, string pdcol = DefPriDarkColor, string bgcol = DefBgColor, string brdrcol = DefBrdColor, string brdrdkcol = DefBrdDarkColor) 
        {
            PriColor = pcol;
            PriDarkColor = pdcol;
            BgColor = bgcol;
            BrdrColor = brdrcol;
            BrdrDarkColor = brdrdkcol;
        }

        public string CreateCss()
        {
            StringBuilder sb = new StringBuilder();
            sb.AppendLine(Fieldset);
            sb.AppendLine(Body);
            sb.AppendLine(Link);
            sb.AppendLine(LinkHover);
            sb.AppendLine(TextPrimary);
            sb.AppendLine(ListGroupItem);
            sb.AppendLine(TableBorderTop);
            sb.AppendLine(TableBorderBottom);
            sb.AppendLine(TableBackground);
            sb.AppendLine(TableBordered);
            sb.AppendLine(TableBorderedBorder);
            sb.AppendLine(MediaMax768pxTableResponsive);
            sb.AppendLine(FormControlBorder);
            sb.AppendLine(BtnAction);
            sb.AppendLine(BtnDefault);
            sb.AppendLine(BtnDefaultAction);
            sb.AppendLine(BtnDefaultDisabled);
            sb.AppendLine(BtnPrimary);
            sb.AppendLine(BtnPrimaryAction);
            sb.AppendLine(BtnPrimaryDisabled);
            sb.AppendLine(BtnLink);
            sb.AppendLine(BtnLinkAction);
            sb.AppendLine(DropDownMenuAction);
            sb.AppendLine(DropDownMenuActive);
            sb.AppendLine(InputGroupAddon);
            sb.AppendLine(NavOpen);
            sb.AppendLine(NavTabs);
            sb.AppendLine(NavTabsListActive);
            sb.AppendLine(NavTabsListHover);
            sb.AppendLine(NavTabsJustified);
            sb.AppendLine(NavPills);
            sb.AppendLine(NavCaret);
            sb.AppendLine(NavCaretHover);
            sb.AppendLine(NavBarInverse);
            sb.AppendLine(Pagination);
            sb.AppendLine(PaginationActive);
            sb.AppendLine(PaginationDisabled);
            sb.AppendLine(PagerBorder);
            sb.AppendLine(LabelPrimaryBg);
            sb.AppendLine(BadgeColor);
            sb.AppendLine(ThumbnailAction);
            sb.AppendLine(ProgressBarBg);
            sb.AppendLine(ListGroupItemColors);

            return sb.ToString();
        }

        public string Fieldset
        {
            get { return string.Format(@"fieldset { border-color: {0}; }", BrdrColor); }
        }

        public string Body
        {
            get { return string.Format(@"body { border-color: {0}; }", BrdrColor); }
        }

        public string Link
        {
            get { return string.Format(@"a { color: {0}; }", PriColor);  }
        }

        public string LinkHover
        {
            get { return string.Format(@"a:hover, a:focus { color: {0}; }", PriDarkColor);  }
        }

        public string TextPrimary
        {
            get { return string.Format(@".text-primary { color: {0}; }", PriColor);  }
        }

        public string ListGroupItem
        {
            get { return string.Format(@".list-group-item { background-color: {0}; border-color: {1}; }", BgColor, BrdrColor);  }
        }

        public string TableBorderTop
        {
            get
            {
                return string.Format(@".table thead > tr > th, .table tbody > tr > th, .table tfoot > tr > th,
                        .table thead > tr > td, .table tbody > tr > td, .table tfoot > tr > td { border-top: 1px solid {0}; }", PriColor);
            }
        }

        public string TableBorderBottom
        {
            get { return string.Format(@".table tbody + tbody { border-top: 2px solid {0}; }", PriColor); }
        }

        public string TableBackground
        {
            get { return string.Format(@".table .table { background-color: {0}; }", BgColor); }
        }

        public string TableBordered
        {
            get { return string.Format(@".table-bordered { border: 1px solid {0}; }", PriColor); }
        }

        public string TableBorderedBorder
        {
            get
            {
                return string.Format(@".table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th,
                        .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td { border-top: 1px solid {0}; }", PriColor);
            }
        }

        public string MediaMax768pxTableResponsive
        {
            get { return string.Format(@"@media (max-width: 768px) { .table-MediaMax768pxTableResponsive { border: 1px solid {0}; }}", PriColor); }
        }

        public string FormControlBorder
        {
            get { return string.Format(@".form-control { border: 1px solid {0}; }", PriColor); }
        }

        public string BtnAction
        {
            get { return string.Format(@".btn:hover, .btn:focus { color: {0}; }", PriDarkColor); }
        }

        public string BtnDefault
        {
            get { return string.Format(@".btn-default { background-color: {0}; border-color: {1}; }", BgColor, PriColor); }
        }

        public string BtnDefaultAction
        {
            get
            {
                return string.Format(@".btn-default:hover, .btn-default:focus, .btn-default:active, .btn-default.active, .open .dropdown-toggle.btn-default {
                    background-color: {0}; border-color: {1}; }", BgColor, BrdrColor);
            }
        }

        public string BtnDefaultDisabled
        {
            get
            {
                return string.Format(@".btn-default.disabled, .btn-default[disabled], fieldset[disabled] .btn-default, 
                    .btn-default.disabled:hover, .btn-default[disabled]:hover, fieldset[disabled] .btn-default:hover,
                    .btn-default.disabled:focus, .btn-default[disabled]:focus, fieldset[disabled] .btn-default:focus, 
                    .btn-default.disabled:active, .btn-default[disabled]:active, fieldset[disabled] .btn-default:active, 
                    .btn-default.disabled.active, .btn-default[disabled].active, fieldset[disabled] .btn-default.active { 
                        background-color: {0}; border-color: {1}; }", BgColor, PriColor);
            }
        }

        public string BtnPrimary
        {
            get { return string.Format(@".btn-primary { background-color: {0}; border-color: {1}; }", BgColor, PriColor); }
        }

        public string BtnPrimaryAction
        {
            get
            {
                return string.Format(@".btn-primary:hover, .btn-primary:focus, .btn-primary:active, .btn-primary.active, .open .dropdown-toggle.btn-primary {
                    background-color: {0}; border-color: {1}; }", BgColor, BrdrColor);
            }
        }

        public string BtnPrimaryDisabled
        {
            get
            {
                return string.Format(@".btn-primary.disabled, .btn-primary[disabled], fieldset[disabled] .btn-primary, 
                    .btn-primary.disabled:hover, .btn-primary[disabled]:hover, fieldset[disabled] .btn-primary:hover,
                    .btn-primary.disabled:focus, .btn-primary[disabled]:focus, fieldset[disabled] .btn-primary:focus, 
                    .btn-primary.disabled:active, .btn-primary[disabled]:active, fieldset[disabled] .btn-primary:active, 
                    .btn-primary.disabled.active, .btn-primary[disabled].active, fieldset[disabled] .btn-primary.active { 
                        background-color: {0}; border-color: {1}; }", BgColor, PriColor);
            }
        }

        public string BtnLink
        {
            get { return string.Format(@".btn-link { color: {0}; }", PriColor); }
        }

        public string BtnLinkAction
        {
            get { return string.Format(@".btn-link:hover, .btn-link:focus { color: {0}; }", PriDarkColor); }
        }

        public string DropDownMenuAction
        {
            get { return string.Format(@".dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus { background-color: {0}; }", PriColor); }
        }

        public string DropDownMenuActive
        {
            get { return string.Format(@".dropdown-menu > .active > a, .dropdown-menu > .active > a:hover, .dropdown-menu > .active > a:focus { background-color: {0}; }", PriColor); }
        }

        public string InputGroupAddon
        {
            get { return string.Format(@".input-group-addon { border: 1px solid {0}; }", PriDarkColor); }
        }

        public string NavOpen
        {
            get { return string.Format(@".nav .open > a, .nav .open > a:hover, .nav .open > a.focus { border-color: {0}; }", PriColor); }
        }

        public string NavTabs
        {
            get { return string.Format(@".nav-tabs { border-bottom: 1px solid {0}; }", PriColor); }
        }

        public string NavTabsListHover
        {
            get { return string.Format(@".nav-tabs > li > a:hover { border-color: {0} {0} {0};", PriColor); }
        }

        public string NavTabsListActive
        {
            get { return string.Format(@".nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus { border: 1px solid {0}; background-color: {1}; }", PriColor, BgColor); }
        }

        public string NavTabsJustified
        {
            get { return string.Format(@".nav-tabs.nav-justified > li > a, .nav-tabs-justified > .active > a { border-bottom-color: {0}; }", BgColor); }
        }

        public string NavPills
        {
            get { return string.Format(@".nav-pills > li.active > a, .nav-pills > li.active > a:hover, .nav-pills > li.active > a:focus { background-color: {0}; }", PriColor); }
        }

        public string NavCaret
        {
            get { return string.Format(@".nav .caret { border-top-color: {0}; border-bottom-color: {0}; }", PriColor); }
        }

        public string NavCaretHover
        {
            get { return string.Format(@".nav a:hover .caret { border-top-color: {0}; border-bottom-color: {0}; }", PriDarkColor); }
        }

        public string NavBarInverse
        {
            get { return string.Format(@".navbar-inverse { background-color: {0}; }", PriDarkColor); }
        }

        public string Pagination
        {
            get { return string.Format(@".pagination > li > a, .pagination > li > span { border: 1px solid {0}; }", PriColor); }  
        }

        public string PaginationActive
        {
            get { return string.Format(@".pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover,
                    .pagination > .active > a:focus, .pagination > .active > span:focus { background-color: {0}; border-color: {0}; }", PriColor);
            }
        }

        public string PaginationDisabled
        {
            get { return string.Format(@".pagination > .disabled > span, .pagination > .disabled > a, .pagination > .disabled > a:hover, .pagination > .disabled > a:focus { 
                        border-color: {0}; }", BgColor); }
        }

        public string PagerBorder
        {
            get { return string.Format(@".pager li > a, .pager li > span { border: 1px solid {0}; }", BgColor); }
        }

        public string LabelPrimaryBg
        {
            get { return string.Format(@".label-primary { background-color: {0}; }", PriColor); }
        }

        public string BadgeColor
        {
            get { return string.Format(@"a.list-group-item.active > .badge, .nav-pills > .active > a > .badge { color: {0}; }", PriColor); }
        }

        public string ThumbnailAction
        {
            get { return string.Format(@"a.thumbnail:hover, a.thumbnail:focus { border-color: {0}; }", PriColor); }
        }

        public string ProgressBarBg
        {
            get { return string.Format(@".progress-bar { background-color: {0}; }", PriColor); }
        }

        public string ListGroupItemColors
        {
            get { return string.Format(@".list-group-item { background-color: {0}; border: 1px solid {1}; }", BgColor, PriColor); }
        }


    }
}